//
//  ShenfenrenzhengViewController.m
//  盘盈贷
//
//  Created by iOS on 15/3/26.
//  Copyright (c) 2015年 Yunpeng Technologies. All rights reserved.
//

#import "ShenfenrenzhengViewController.h"
#import "AFHTTPRequestOperationManager.h"
@interface ShenfenrenzhengViewController ()
{
    UITextField *name;
    UITextField *password;
}
@end

@implementation ShenfenrenzhengViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title  = @"身份认证";
    self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
    CGFloat width = self.view.frame.size.width;
    CGFloat height = self.view.frame.size.height;
    
    name = [[UITextField alloc] initWithFrame:CGRectMake(30, 80, width / 1.2, 40)];
    name.placeholder = @"请填写您的真实姓名";
    name.borderStyle = UITextBorderStyleRoundedRect;
    name.clearButtonMode = UITextFieldViewModeWhileEditing;
    name.textColor = [UIColor grayColor];
    name.borderStyle = UITextBorderStyleLine;
    [self.view addSubview:name];
    [name release];
    
    
    password = [[UITextField alloc] initWithFrame:CGRectMake(30, 130, width / 1.2, 40)];
    password.placeholder = @"请填写18位身份证号码";
    password.borderStyle = UITextBorderStyleRoundedRect;
    password.clearButtonMode = UITextFieldViewModeWhileEditing;
    password.textColor = [UIColor grayColor];
    password.secureTextEntry = YES; //密码
    password.borderStyle = UITextBorderStyleLine;
    [self.view addSubview:password];
    [password release];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(30, 200, width / 1.2, 40);
    button.center = CGPointMake(width / 2, 200);
    button.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:14];
    [button setTitle:@"认证" forState:UIControlStateNormal];
    button.backgroundColor = [UIColor redColor];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(next:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
   
}
- (void)next:(id)sender {
    NSLog(@"%@", self.name);
     NSLog(@"%@", name.text);
     NSLog(@"%@", password.text);
    NSString *str = [NSString stringWithFormat:@"http://www.cloudpeng.com:8102/audit/doIDAudit?username=%@&realname=%@&idnumber=%@",self.name, name.text, password.text];
    
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
   // manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
    [manager GET:str parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        if ([[responseObject objectForKey:@"IsSuccess"]isEqual:@"1"]) {
            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"身份证已存在" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
            [alert show];
        }
        NSLog(@"issuccess:%@", [responseObject objectForKey:@"IsSuccess"]);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"~~~~~~~%@",error);
    }];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
